package com.ikun.common.search;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName PageResult
 * @Description: 分页查询结果vo
 * @CreateDate: 2024/4/16 2:23
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("分页查询统一结果集vo")
public class PageResult<T>{
    private Long total;

    private List<T> list;


    /**
     * 返回一个空的分页结果集对象
     * @return
     * @param <T>
     */
    public static <T> PageResult<T> emptyPageResult(){
        return new PageResult<>(0L, new ArrayList<>());
    }

    /**
     * 返回一个分页结果集对象
     * @param total
     * @param data
     * @return
     * @param <T>
     */
    public static <T> PageResult<T> getInstance(Long total, List<T> data){
        return new PageResult<>(total, data);
    }
}
